package com.heima.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.heima.daoInterface.IUserDao;
import com.heima.domain.User;
import com.heima.serviceInterface.IUserService;
import com.heima.tools.MD5Utils;
@Service
@Transactional
public class UserServiceImpl implements IUserService {
	@Resource
	private IUserDao userDao;
	@Override
	public User login(User model) {
		return userDao.findByNamedQuery("findByNameAndPassword", model.getUsername(),MD5Utils.md5(model.getPassword()));
	}
	@Override
	public void edit(User model) {
		
		userDao.executeByNamedQuery("editPassword", MD5Utils.md5(model.getPassword()),model.getId());
	}

}
